﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using IDAL;
using Model;

namespace DAL
{
    public class FinalCheckItem : BaseRepository<FinalCheckItemInfo>, IFinalCheckItem
    {
        #region 静态字段部分
        private const string PARM_FINALCHECKITEM_PRODUCTSN = "@ProductSN";
        private const string PARM_FINALCHECKITEM_RECORDTIME = "@RecordTime";
        #endregion

        #region 检索部分
        public IList<FinalCheckItemInfo> GetFinalCheckItembySNDT(string productSN, DateTime recordTime)
        {
            SqlParameter[] parms = GetSNDTParameters();
            parms[0].Value = productSN;
            parms[1].Value = recordTime;
            return ExcuteSqlToGetEntities("FinalCheckItem_selectbySNDT", parms);
        }
        #endregion

        #region 参数部分
        private static SqlParameter[] GetSNDTParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_FINALCHECKITEM_PRODUCTSN, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_FINALCHECKITEM_RECORDTIME, SqlDbType.DateTime, 8)
                };
            return parms;
        }
        #endregion

        #region 重新基类部分
        public override FinalCheckItemInfo GetEntityRecord(SqlDataReader rdr)
        {
            FinalCheckItemInfo pro = new FinalCheckItemInfo
            {
                ProductSN = rdr.GetValue(0).ToString(),
                RecordTime = rdr.GetDateTime(1),
                TestItem = rdr.GetValue(2).ToString(),
                Result = rdr.GetValue(3).ToString(),
                IsPass = rdr.GetBoolean(4)
            };
            return pro;
        }
        #endregion
    }
}
